<?php /*a:1:{s:58:"D:\web\www\tp5.1\public/../app/admin\view\welfare\add.html";i:1526390289;}*/ ?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/frame/layui/css/layui.css">
    <link rel="stylesheet" href="/static/frame/static/css/style.css">
    <link rel="icon" href="/static/frame/static/image/code.png">
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body class="body">

<form class="layui-form" action="" method="post" id="addform">
  <div class="layui-form-item">
    <label class="layui-form-label">角色</label>
    <div class="layui-input-inline">
      <input type="hidden" name="names">
      <input type="text" class="layui-input" name="names" placeholder="请输入角色名，多个角色间以逗号分隔" onkeyup="value=value.replace(/，/ig,',')">
      </select>
    </div>
  </div>

    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" name="title" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">内容</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容" name="content" class="layui-textarea"></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">物品</label>
        <div class="layui-input-inline">
            <input type="hidden" name="goods" class="layui-input"><input type="number" name="num" class="layui-input" min="1"><span class="sss">添加</span>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">数量</label>
        <div class="layui-input-inline">
            <input type="number" name="num" class="layui-input" min="1">
        </div>
    </div>

      <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <input type="text" name="remark" class="layui-input">
        </div>
    </div>

  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>
    
<input type="text" name="consignee" lay-verify="required" placeholder="请输入" class="layui-input">



<script src="/static/frame/layui/layui.js" charset="utf-8"></script>
<script src="/static/admin/js/comm.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'admin','autocomplete'], function() {
      var form = layui.form,
        layer = layui.layer,
        $ = layui.$, //重点处
        admin = layui.admin,
        autocomplete = layui.autocomplete;

      //自定义验证规则
      form.verify({
        name: function(value) {
          if (value.length < 2) {
            return '标题至少得2个字符啊';
          }
        }
      });

        autocomplete.render({
            elem: $('input[name=consignee]'),
            url: "<?php echo url('ajaxkeywords'); ?>",
            cache: true,
            template_val: '{{d.name}}',
            template_txt: '{{d.name}} <span class=\'layui-badge layui-bg-gray\'>{{d.name}}</span>',
            onselect: function (resp) {
                //$('input[name=phone_number]').val(resp.phone_number), $('input[name=address]').val(resp.address)
            }
        }),



//https://www.cnblogs.com/jingliwufadaodai/p/5756018.html



      //创建一个编辑器

      //监听指定开关
      // form.on('submit(demo1)', function(data) {
      //   $.post('<?php echo url('add'); ?>', $('#addform').serialize(),
      //     function(data) {
      //       if (data.code == 1) {
      //         layer.alert(data.msg, {
      //           skin: 'layui-layer-molv' //样式类名
      //             ,
      //           closeBtn: 0
      //         }, function() {
      //           location.href = data.url;
      //         });
      //       } else {
      //         layer.msg(data.msg);
      //       }
      //     });
      //   return false;
      // });

        form.on('submit(demo1)', function(data){
            admin.action("<?php echo url('admin/WelfareM/add'); ?>",$("#addform").serialize());
            return false;
        });

    });


/*
    layui.use(['datagrid', 'autocomplete', 'form', 'jquery', 'element', 'laydate'],function(){
        var $ = layui.jquery, autocomplete = layui.autocomplete, laydate = layui.laydate;
        autocomplete.render({
            elem: $('input[name=consignee]')[0],
            url: '',
            cache: true,
            template_val: '{{d.consignee}}',
            template_txt: '{{d.consignee}} <span class=\'layui-badge layui-bg-gray\'>{{d.phone_number}}</span>',
            onselect: function (resp) {
                $('input[name=phone_number]').val(resp.phone_number), $('input[name=address]').val(resp.address)
            }
        }),
        laydate.render({
            elem: $('input[name=receive_date]')[0]
        }),
        layui.onevent('datagrid', 'tool(goods)', function (e) {
            if (e.filter == 'add')
            {
                var data = layui.datagrid.getData('order');
                data[e.data.id] == undefined ? (data[e.data.id] = {goods: e.data.id, name: e.data.name, price: parseFloat(e.data.preset_amount), quantity: 1}) : (data[e.data.id].quantity = parseInt(data[e.data.id].quantity) + 1);
                layui.datagrid.reload('order', data);
            }
        }),
        layui.onevent('datagrid', 'tool(order)', function (e) {
            if (e.filter == 'delete')
            {
                var data = layui.datagrid.getData('order');
                data[e.data.id] != undefined && (delete data[e.data.id], layui.datagrid.reload('order', data));
            }

        })
    });

*/






</script>

</body>
</html>